/**
 * 
 */
package org.destiny.account.richclient.form;

import javax.swing.JComponent;
import javax.swing.JOptionPane;

import org.destiny.account.entity.queryCondition.CustomerQueryCondition;
import org.springframework.binding.form.CommitListener;
import org.springframework.binding.form.FormModel;
import org.springframework.richclient.application.Application;
import org.springframework.richclient.command.CommandGroup;
import org.springframework.richclient.form.AbstractForm;
import org.springframework.richclient.form.FormModelHelper;
import org.springframework.richclient.form.builder.TableFormBuilder;

/**
 * @author kunrey_lew
 *
 */
public class CustomerQueryForm extends AbstractForm implements CommitListener {

	public CustomerQueryForm(){
		super(FormModelHelper.createFormModel(new CustomerQueryCondition(), "CustomerQueryForm"),"CustomerQueryForm");
	}
	/* (non-Javadoc)
	 * @see org.springframework.richclient.form.AbstractForm#createFormControl()
	 */
	@Override
	protected JComponent createFormControl() {
		TableFormBuilder builder = new TableFormBuilder(getBindingFactory());
		builder.add("name");
		builder.getLayoutBuilder().gapCol().row();
		builder.getLayoutBuilder().cell(CommandGroup.createCommandGroup(new Object[]{getCommitCommand()}).createButtonBar());
		
		this.attachFormErrorGuard(getCommitCommand());
		this.getFormModel().addCommitListener(this);
		
		return builder.getForm();
	}
	@Override
	protected String getCommitCommandFaceDescriptorId() {
		return "queryCommand";
	}
	@Override
	public void postCommit(FormModel formModel) {
		super.postCommit(formModel);
		JOptionPane.showMessageDialog(Application.instance().getActiveWindow().getControl(), "Do Search ...");
	}
}
